package insta.project;

import java.util.ArrayList;

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class SongsGroup extends ActivityGroup {

	public static SongsGroup group;

	private ArrayList<View> history;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		this.history = new ArrayList<View>();
		group = this;

		Intent intent = new Intent().setClass(this, SongsActivity.class);
		intent.putExtra("playlist_number", -1);

		View view = getLocalActivityManager().startActivity(
				"SongsActivity",intent
						.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
				.getDecorView();

		replaceView(view);
	}

	public void replaceView(View v) {
		history.add(v);
		setContentView(v);
	}

	public void back() {
		if (history.size() > 0) {
			history.remove(history.size() - 1);
			setContentView((View) history.get(history.size() - 1));
		} else {
			finish();
		}
	}

	@Override
	public void onBackPressed() {
		SongsGroup.group.back();
		return;
	}
}